//
//  WeatherEndpoint.swift
//  NewsApp With SwiftUI Framework
//
//  Created by Алексей Воронов on 30.09.2019.
//  Copyright © 2019 Алексей Воронов. All rights reserved.
//

import Foundation

enum WeatherEndpoint: EndpointProtocol {
    case getCurrentWeather(latitude: Double, longitude: Double)
    
    var baseURL: String {
        return "https://api.openweathermap.org"
    }
//    https://api.openweathermap.org/data/2.5/onecall?lat=55.5&lon=37.5&appid=43ba19fdb3ec91f33f3e447a329f2039
    var absoluteURL: String {
        switch self {
        case let .getCurrentWeather(latitude, longitude):
            return baseURL + "/data/2.5/onecall?appid=\(Container.weatherAPIKey)&lat=\(latitude)&lon=\(longitude)"
        }
    }
    
    var params: [String : String] {
        switch self {
        case .getCurrentWeather:
            return ["lang": locale]
        }
    }
    
    var headers: [String : String] {
        return [
            "Content-type": "application/json",
            "Accept": "application/json"
        ]
    }
}
